package com.huawei.hms.support.api.push.c;

import android.content.Context;
import com.huawei.hms.android.HwBuildEx.VERSION;
import com.huawei.hms.support.log.HMSLog;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

public abstract class a {
    private static final Object a = new Object();
    private static int b = -1;

    private static boolean c(Context context) {
        HMSLog.d("CommFun", "existFrameworkPush:" + b);
        try {
            File file = new File("/system/framework/" + "hwpush.jar");
            if (b()) {
                HMSLog.d("CommFun", "push jarFile is exist");
            } else if (!file.isFile()) {
                return false;
            } else {
                HMSLog.d("CommFun", "push jarFile is exist");
            }
            return true;
        } catch (Exception e) {
            HMSLog.e("CommFun", "get Apk version faild ,Exception e= " + e.toString());
            return false;
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static boolean a(android.content.Context r5) {
        /*
        r1 = 0;
        r0 = 1;
        r2 = "CommFun";
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = "existFrameworkPush:";
        r3 = r3.append(r4);
        r4 = b;
        r3 = r3.append(r4);
        r3 = r3.toString();
        com.huawei.hms.support.log.HMSLog.d(r2, r3);
        r2 = a;
        monitor-enter(r2);
        r3 = -1;
        r4 = b;	 Catch:{ all -> 0x0040 }
        if (r3 == r4) goto L_0x002c;
    L_0x0024:
        r3 = b;	 Catch:{ all -> 0x0040 }
        if (r0 != r3) goto L_0x002a;
    L_0x0028:
        monitor-exit(r2);	 Catch:{ all -> 0x0040 }
    L_0x0029:
        return r0;
    L_0x002a:
        r0 = r1;
        goto L_0x0028;
    L_0x002c:
        r3 = c(r5);	 Catch:{ all -> 0x0040 }
        if (r3 == 0) goto L_0x003c;
    L_0x0032:
        r3 = 1;
        b = r3;	 Catch:{ all -> 0x0040 }
    L_0x0035:
        monitor-exit(r2);	 Catch:{ all -> 0x0040 }
        r2 = b;
        if (r0 == r2) goto L_0x0029;
    L_0x003a:
        r0 = r1;
        goto L_0x0029;
    L_0x003c:
        r3 = 0;
        b = r3;	 Catch:{ all -> 0x0040 }
        goto L_0x0035;
    L_0x0040:
        r0 = move-exception;
        monitor-exit(r2);	 Catch:{ all -> 0x0040 }
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.hms.support.api.push.c.a.a(android.content.Context):boolean");
    }

    private static boolean b() {
        try {
            Class cls = Class.forName("huawei.cust.HwCfgFilePolicy");
            int intValue = ((Integer) cls.getDeclaredField("CUST_TYPE_CONFIG").get(cls)).intValue();
            File file = (File) cls.getDeclaredMethod("getCfgFile", new Class[]{String.class, Integer.TYPE}).invoke(cls, new Object[]{"jars/hwpush.jar", Integer.valueOf(intValue)});
            if (file != null && file.exists()) {
                HMSLog.d("CommFun", "get push cust File path is " + file.getCanonicalPath());
                return true;
            }
        } catch (ClassNotFoundException e) {
            HMSLog.e("CommFun", "HwCfgFilePolicy ClassNotFoundException");
        } catch (SecurityException e2) {
            HMSLog.e("CommFun", "check cust exist push SecurityException.");
        } catch (NoSuchFieldException e3) {
            HMSLog.e("CommFun", "check cust exist push NoSuchFieldException.");
        } catch (NoSuchMethodException e4) {
            HMSLog.e("CommFun", "check cust exist push NoSuchMethodException.");
        } catch (IllegalArgumentException e5) {
            HMSLog.e("CommFun", "check cust exist push IllegalArgumentException.");
        } catch (IllegalAccessException e6) {
            HMSLog.e("CommFun", "check cust exist push IllegalAccessException.");
        } catch (InvocationTargetException e7) {
            HMSLog.e("CommFun", "check cust exist push InvocationTargetException.");
        } catch (IOException e8) {
            HMSLog.e("CommFun", "check jarFile exist but get not path");
        }
        return false;
    }

    public static long b(Context context) {
        long j = -1;
        try {
            return (long) context.getPackageManager().getPackageInfo("com.huawei.android.pushagent", 0).versionCode;
        } catch (Exception e) {
            HMSLog.e("CommFun", "get nc versionCode error");
            return j;
        }
    }

    public static boolean a() {
        return VERSION.EMUI_SDK_INT >= 21;
    }
}
